package com.atguigu.srb.sms;

import com.atguigu.srb.sms.feign.MyRandomRule;
import com.netflix.loadbalancer.IRule;
import feign.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@ComponentScan(basePackages = "com.atguigu.srb")
@EnableFeignClients//扫描启动类所在的包和子包下的FeignClient注解标注的接口并创建对象注入到容器中
public class ServiceSmsApplication {
    public static void main(String[] args) {
        SpringApplication.run(ServiceSmsApplication.class,args);
    }

    //向容器中注入feign客户端的日志级别(输出哪些日志)对象
    @Bean
    public Logger.Level level(){
        //feign客户端的日志默认以debug级别输出，需要降低slf4j日志输出级别为debug
        return Logger.Level.FULL;
    }
    //默认ribbon以轮询方式负载均衡
    //IRule
    //向容器注入自定义的负载均衡策略
    @Bean
    public IRule myrule(){
        return new MyRandomRule();
    }
}
